/**
 * 钓鱼提示的对象池
 */
class TipsPool{

    private static _Pool:eui.Label[] = [];
	private static _poolMax:number = 10;
	private static _poolIndex:number = 0;

    constructor()
    {
        
    }

    /**
	 * 生成Tips
     * effectType: 0 无 1 显示后渐渐隐藏 2 显示后上升消失
	 */
	public static createTips(str:string, parent, effectType:number = 0){
        if(!parent) return;
		let tips:eui.Label = null;
		let pool = TipsPool._Pool;
		let max = TipsPool._poolMax;

		if(pool.length < max){
			tips = new eui.Label();
			tips.cacheAsBitmap = true;
			
			pool.push(tips);
		}else{
			if(TipsPool._poolIndex < pool.length){
				tips = pool[TipsPool._poolIndex];
				TipsPool._poolIndex++;
			}else{
				TipsPool._poolIndex = 0;
			}
		}

		if(tips){
			tips.text = str;
			tips.visible = true;

			tips.alpha = 0;
            tips.size = 50;
            tips.bold = true;
			tips.textColor = 0xffffff;
            parent.addChild(tips);
			
			egret.Tween.removeTweens(tips);
            if(effectType!=0)
            {
                if(effectType == 1)
                {
                    tips.alpha = 1;
                    egret.Tween.get(tips).to({alpha:0},500).call(()=>{
                        if(tips.parent)
                            tips.parent.removeChild(tips);
                    });
                }
            }
            else
            {
                tips.alpha = 1;
            }
		}	
		return tips;
	}

    /**
	 * 释放缓存
	 */
	public static release(){
		for(let v of TipsPool._Pool)
		{
			v = null;
		}
		TipsPool._Pool = [];
		TipsPool._poolIndex = 0;
	}

}